package pl.zmudzinski.jdk.newsletter;

import com.google.inject.Injector;
import com.google.inject.Guice;
import pl.zmudzinski.jdk.newsletter.publisher.NewsletterPublisher;

import java.util.Observable;
import java.util.Observer;

/**
 * @author lukasz.zmudzinski
 */
public class NewsletterExample {
    public static void main(String[] args){
        Injector injector = Guice.createInjector(new NewsletterModule());
        NewsletterPublisher publisher = injector.getInstance(NewsletterPublisher.class);
        Observer clientOne = injector.getInstance(Observer.class);
        Observer clientTwo = injector.getInstance(Observer.class);
        // not nice that Observable is a class
        ((Observable)publisher).addObserver(clientOne);
        ((Observable)publisher).addObserver(clientTwo);
        publisher.publish();
    }
}
